<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title>预览</title>

    <script src="./utils/vue-2.6.11/vue.min.js"></script>
    <script src="./utils/vue-router-3.1.3/vue-router.min.js"></script>
    <script src="./utils/element-ui/index.js"></script>
    <script src="./utils/tinymce-5.3.2/tinymce.min.js"></script>

    <style>
      body {
        margin: 0;
        padding: 0;
        overflow-x: hidden;
        -moz-osx-font-smoothing: grayscale;
        -webkit-font-smoothing: antialiased;
        text-rendering: optimizeLegibility;
        height: calc(100vh - 33px);
        padding: 12px;
        box-sizing: border-box;
        font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
      }

      input,
      textarea {
        font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
      }
    </style>

    <script>
      // 表单ID,存在则代表为更新操作
      var opFormId

      /**
       * id: 表单ID
       * op: 操作类型
       */
      var opParams = {}

      function init() {
        let search = window.location.search
        if (!search) return

        search = search.substring(1)

        if (!search) return

        search = search.split('&')

        if (search.length < 1) return

        for (let i = 0; i < search.length; i++) {
          let p = search[i]

          if (!p) return
          p = p.split('=')

          if (p.length === 2) {
            opParams[p[0]] = p[1]
          }

          if (p.length > 0 && p[0] == 'id') opFormId = p[1]
        }
      }

      init()

      /**
       * 向父页面发出消息，请求关闭子窗口
       */
      function closeMe() {
        top.postMessage({
          type: 'close',
          data: opParams.tab
        }, opParams.origin ? opParams.origin : opParams.baseUrl)
      }
    </script>
  </head>
  <body>
    <noscript>
      <strong>抱歉，javascript被禁用，请开启后重试。</strong>
    </noscript>

    <div id="previewApp"></div>
  </body>
</html>
